package vue;

import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;

import model.Fourmiliere;
import model.MainModel;
import model.MonTimer;

public class AffichageTexte extends TimerTask {
	
	Timer mainTimer = new Timer();
	private MainModel model;
	
	private HashMap<String,Object> report;
	
	
	public AffichageTexte(MainModel _model, int _periodInMilliS) {
		model = _model;
		report = new HashMap<String, Object>();
		System.out.println("############ SIMULATION FOURMILIERE ############");
		mainTimer.schedule(this, 0, _periodInMilliS);
	}
	
	@Override
	public void run() {
		System.out.println("----------------------------------");
		printFourmiliere(model.getFourmiliere());
		System.out.println(MonTimer.getNom_saison()+" le "+MonTimer.getJours()+"  -  "+MonTimer.getHeures()+":"+MonTimer.getMins() );
		System.out.println("----------------------------------");
	}
	
	private void printFourmiliere(Fourmiliere f){
		
		System.out.println("Stock de la fourmiliere : "+f.getFoodStock());
		//System.out.println("Nb de cadavre dans la fourmiliere : "+f.getNbCadavre());
		System.out.println("Nb de fourmis : "+f.getFourmiListSize());
		
		report.clear();
		f.buildReport(report);
		
		if(report.containsKey("oeuf"))
			System.out.println("Nb d'oeufs : "+ report.get("oeuf"));
		if(report.containsKey("larve"))
			System.out.println("Nb de larves : "+ report.get("larve"));
		if(report.containsKey("nymphe"))
			System.out.println("Nb de nymphes : "+ report.get("nymphe"));
		if(report.containsKey("adulte"))
			System.out.println("Nb d'adultes : "+ report.get("adulte"));
		
		
	}

}
